home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
news
/
readers
/
skim-0.8
/
skim-0
/
skim-0.8.4
/
AuthorParseTest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-02-18
|
2KB
|
77 lines
/*
* NAME
* AuthorParseTest.c
* DESCRIPTION
* Test the parser which gets the full name of the Author from the
* "From:" header line. Run this test by typing 'make test' in the source
* directory of skim.
* COPYRIGHT
* AuthorParseTest
* Copyright (C) 1996 Rene W.J. Pijlman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* VERSION
* $Header: /home/rene/sys/CVS_MasterSourceRepository/skim/AuthorParseTest.c,v 1.4 1996/02/18 11:40:17 rene Exp $
* Distributed with Skim version 0.8.4.
*/
#include <string.h>
#include <stdio.h>
#include "VarBuf.h"
#include "SkimUtils.h"
int main(void)
{
int i;
VarBuf From = VBCreate();
Boolean TestSucceeded = True;
static char * TestPairs[] = {
/* From field. */ /* Expected Author */
"foo@bar.org (Foo Bar)" , "Foo Bar",
"Foo Bar <foo@bar.org>" , "Foo Bar",
"foo@bar.org" , "foo@bar.org",
"\"Foo Bar\" <foo@bar.org>" , "Foo Bar",
"foo@bar.org ()" , "foo@bar.org"
};
for ( i = 0; i < sizeof TestPairs / sizeof TestPairs[0]; i += 2 )
{
VBReset( From );
VBPrintf( From, "%s", TestPairs[i] );
AuthorFromFromField( From );
if( strcmp(VBAsString(From), TestPairs[i+1]) )
{
fprintf( stderr,
"AuthorFromFromField() failed '%s' --> '%s', expected '%s'\n",
TestPairs[i], VBAsString(From), TestPairs[i+1] );
TestSucceeded = False;
}
}
VBDestroy( From );
if ( TestSucceeded )
{
SIOPrintf( StandardOutput, "OK\n" );
}
return TestSucceeded ? EXIT_SUCCESS : EXIT_FAILURE;
}